package com.ecfront.test.dao;

import java.util.Iterator;
import java.util.List;
import com.ecfront.dao.PayGoodsDAO;
import com.ecfront.pojo.GoodsImpl;
import com.ecfront.pojo.Pay;
import com.ecfront.pojo.PayGoods;
import junit.framework.TestCase;

public class testPayGoods extends TestCase {
	private static final PayGoodsDAO payGoodsDao = (PayGoodsDAO)SpringUtilTest.getBean("PayGoodsDAO");
	//save or update test
	public void testSaveOrUpdate(){
		PayGoods pg = new PayGoods();
		pg.setPrice(2000.0);
		pg.setTotal(2);
		
		Pay pay = new Pay();
		pay.setId(1);
		pg.setPay(pay);
		
		GoodsImpl gi = new GoodsImpl();
		gi.setId(1);
		pg.setGoodssub(gi);
		
		payGoodsDao.save(pg);
	}
	//findAll test
	public void testFindAll(){
		List list = payGoodsDao.findAll();
		for(Iterator iter = list.iterator();iter.hasNext();){
			PayGoods pg = (PayGoods)iter.next();
			System.out.println(pg.getPrice());
			
			System.out.println(pg.getGoodssub().getGood().getName());
			System.out.println(pg.getPay().getAdd());
		}
	}
	//findById test
	public void testFindById(){
		PayGoods pg = payGoodsDao.findById(1);
		System.out.println(pg.getPrice());
		System.out.println(pg.getGoodssub().getGood().getName());
		System.out.println(pg.getPay().getAdd());
	}
	//delete test
	public void testDel(){
		PayGoods pg = new PayGoods();
		pg.setId(2);
		
		payGoodsDao.delete(pg);
	}
	//property test
	public void testProperty(){
		List list = payGoodsDao.findByPgCount(2);
		for(Iterator iter = list.iterator();iter.hasNext();){
			PayGoods pg = (PayGoods)iter.next();
			System.out.println(pg.getPrice());
			
			System.out.println(pg.getGoodssub().getGood().getName());
			System.out.println(pg.getPay().getAdd());
		}
	}
}
